home *** CD-ROM | disk | FTP | other *** search
- /*
- * Copyright (C) 1993, 1994 Marc Parmet.
- * This file is part of the Macintosh port of GNU Emacs.
- *
- * GNU Emacs is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- */
-
- #if defined(THINK_C)
- #include <MacHeaders>
- #else
- #include <Types.h>
- #include <Memory.h>
- #include <Quickdraw.h>
- #include <Windows.h>
- #include <ToolUtils.h>
- #include <SegLoad.h>
- #endif
-
- #include "config.h"
- #include "lisp.h"
- #include "regex.h"
-
- #if defined(powerc)
- QDGlobals qd;
- #endif
-
- static int
- get_preferred_stack_size(void)
- {
- int err,stack_size,**sh;
-
- err = get_preference('DATA',129,&sh);
- if (err) return MIN_STACK_SIZE;
- stack_size = **sh;
- DisposHandle((Handle)sh);
- if (stack_size < MIN_STACK_SIZE) return MIN_STACK_SIZE;
- return stack_size;
- }
-
- static void
- load_dumped_data(void)
- {
- // Do C initializations not saved in the database
-
- init_alloc_once();
-
- // from init_obarray
- {
- extern int read_buffer_size;
- extern char *read_buffer;
- read_buffer_size = 100;
- read_buffer = (char *) malloc (read_buffer_size);
- }
-
- init_eval_once();
-
- // from syms_of_macros
- {
- extern char *kbd_macro_buffer;
- extern int kbd_macro_bufsize;
- kbd_macro_bufsize = 100;
- kbd_macro_buffer = (char *) malloc (kbd_macro_bufsize);
- }
-
- // from syms_of_minibuf
- {
- extern int minibuf_level;
- extern char *minibuf_prompt;
- extern int minibuf_save_vector_size;
- struct minibuf_save_data {
- char *prompt;
- int prompt_width;
- Lisp_Object help_form;
- Lisp_Object current_prefix_arg;
- };
- extern struct minibuf_save_data *minibuf_save_vector;
- minibuf_level = 0;
- minibuf_prompt = 0;
- minibuf_save_vector_size = 5;
- minibuf_save_vector = (struct minibuf_save_data *) malloc (5 *
- sizeof (struct minibuf_save_data));
- }
-
- // from syms_of_search
- {
- register int i;
- extern int re_max_failures;
- extern unsigned char downcase_table[];
- extern struct re_pattern_buffer searchbuf;
- extern char search_fastmap[];
-
- /* Avoid running out of regexp stack quite so soon.*/
- re_max_failures = 10000;
-
- for (i = 0; i < 0400; i++) {
- downcase_table[i] = (i >= 'A' && i <= 'Z') ? i + 040 : i;
- downcase_table[0400+i] =
- ((i >= 'A' && i <= 'Z') ? i + ('a' - 'A')
- : ((i >= 'a' && i <= 'z') ? i + ('A' - 'a')
- : i));
- }
-
- searchbuf.allocated = 100;
- searchbuf.buffer = (char *) malloc (searchbuf.allocated);
- searchbuf.fastmap = search_fastmap;
- }
-
- // Load the database
- reverse_unexec();
- }
-
- void
- main(void)
- {
- char ***argv;
- int argc,stack_needed;
- KeyMap keys;
- extern char **environ;
- extern int initialized;
- extern int *pure;
-
- stack_needed = get_preferred_stack_size() * 1024;
- init_unix(stack_needed,&environ,&argc,&argv);
- check_traps();
- AEObjectInit();
-
- GetKeys(keys);
- if (BitTst(keys,61)) { /* Test option key */
- // Rebuild the database.
- static char *dump_argv[] = { 0L, "-batch", "-l", "loadup.el", "dump" };
- int i,dump_argc = sizeof(dump_argv) / sizeof(char *);
-
- SetHandleSize((Handle)argv,(dump_argc+1) * sizeof(char *));
- if (MemError()) ExitToShell();
- for (i = 1; i<dump_argc; ++i)
- (*argv)[i] = dump_argv[i];
- (*argv)[dump_argc] = 0L;
- argc = dump_argc;
- initialized = 0;
- }
- else if (BitTst(keys,63)) /* Test shift key */
- // Start up in impure state, no load
- initialized = 0;
- else {
- // Usual startup. Load the database.
- load_dumped_data();
- initialized = 1;
- }
-
- if (!initialized) {
- // Set up pure storage area
- char **h = NewHandle(PURESIZE);
- if (MemError()) ExitToShell();
- MoveHHi(h);
- HLock(h);
- pure = (int *)StripAddress(*h);
- }
-
- MoveHHi((Handle)argv);
- HLock((Handle)argv);
- main1(argc,*argv,environ);
- }
-
- #if defined(powerc)
-
- void
- CtoPstr(char *s)
- {
- char c,d,*t;
-
- t = s;
- d = '\0';
- while (1) {
- c = *s;
- *s = d;
- d = c;
- if (c == '\0') {
- *t = s - t;
- return;
- }
- ++s;
- }
- }
-
- void
- PtoCstr(unsigned char *s)
- {
- int n;
-
- n = s[0];
- while (n != 0) {
- s[0] = s[1];
- ++s;
- --n;
- }
- s[0] = '\0';
- }
-
- #endif
-